// PipelineImpl.groovy
package com.mawenwu.pipeline

class PipelineImpl implements Serializable {
    def caller

    PipelineImpl(caller) {
        this.caller = caller
    }

    // Pulling Source Code Method
    def pullSourceCode(env) {
        caller.withCredentials([caller.usernamePassword(credentialsId: env.git_credentials, usernameVariable: 'GIT_USERNAME', passwordVariable: 'GIT_PASSWORD')]){
            caller.sh "git clone -b ${env.git_branch} ${env.git_url}"
        }
    }

    // Compiling Code Method
    def compileCode(env) {
        caller.sh 'ls -la'
        caller.sh "cd ${env.pom_path}"
        caller.sh 'ls -la'
        caller.sh 'mvn package -Dmaven.test.skip=true'
    }

    // Building and Pushing Docker Image Method
    def dockerImage(env) {

    }

    // Deploying Artifact Method
    def deployArtifact(env) {

    }

    // Sending Notification Method
    def sendMail(env) {

    }
}
